package test.study.concurrent.thread._5_sync.barrier;

import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CyclicBarrier;

@Slf4j
public class _1_CyclicBarrier_Main {

    public static void main(String[] args) {
        CyclicBarrier barrier = new CyclicBarrier(11);
        log.info("1111");
        new Thread(() -> {
            log.info("asdfasdf");
            ThreadUtil.sleep(5000);
            try {
                barrier.await();
            } catch (Exception ex) {
            }
        }).start();

        new Thread(() -> {
            log.info("12312312");
            ThreadUtil.sleep(2000);
            try {
                barrier.await();
            } catch (Exception ex) {
            }
        }).start();
        log.info("2222");
    }
}
